<!DOCTYPE html>
<html lang="en">
<head>
    <link rel="icon" href="/exam-api/static_pc/1896476650888691713.png">
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        a{
            font-size: 20px;
        }
    </style>
</head>
<body>
<script>
    function download(link){
        const xhr = new XMLHttpRequest();
        xhr.open('GET',link)
        xhr.responseType = 'blob'
        xhr.send()
        xhr.onload = function () {
            const fileBlob = xhr.response;
            console.log(fileBlob)
            const fileUrl = URL.createObjectURL(fileBlob)
            console.log(fileUrl)
            const ele = document.createElement('a')
            ele.setAttribute('href',fileUrl)
            ele.setAttribute('download',"")
            ele.click()
            ele.innerHTML = '下载'
            document.body.appendChild(ele)
        }
    }
    download("/v1img/2025/04/07/1909119953203286017.jpg" )
</script>
<a href="/v1img/2025/04/07/1909119953203286017.jpg" download="">可以跨域下载的链接</a>
<a href="https://www.ketangpai.com/images/common/logo_blue.png" download="a7995ad.svg">不可以跨域下载的链接，只能预览</a>
</body>
</html> 